from toee import *

def san_dialog( attachee, triggerer ):
	if (attachee.leader_get() != OBJ_HANDLE_NULL):
		triggerer.begin_dialog( attachee, ((attachee.area * 50) + 150 + (game.random_range(0,2)*2)) )
	elif (attachee.has_met( triggerer )):
		triggerer.begin_dialog( attachee, 50 )
	else:
		triggerer.begin_dialog( attachee, 1 )
	return SKIP_DEFAULT

def san_dying( attachee, triggerer ):
	game.global_flags[364] = 1
	attachee.float_line(12014,triggerer)
	if (attachee.leader_get() == OBJ_HANDLE_NULL):
		game.global_vars[23] = game.global_vars[23] + 1
		if (game.global_vars[23] >= 2):
			game.party[0].reputation_add( 1 )
	else:
		game.global_vars[29] = game.global_vars[29] + 1
	return RUN_DEFAULT

def san_new_map( attachee, triggerer ):
	randy1 = game.random_range(1,12)
	if ((attachee.map == 5014 or attachee.map == 5061) and randy1 >= 8):
		attachee.float_line(12103,triggerer)
	elif ((attachee.map == 5087 or attachee.map == 5017) and randy1 >= 6):
		attachee.float_line(12200,triggerer)
	if ((attachee.map == 5067) and randy1 >= 9):
		attachee.float_line(12095,triggerer)
	return RUN_DEFAULT

def buttin( attachee, triggerer, line):
	npc = find_npc_near(attachee,8000)
	if (npc != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc,line)
		npc.turn_towards(attachee)
		attachee.turn_towards(npc)
	return SKIP_DEFAULT

def equip_transfer( attachee, triggerer ):
	itemA = attachee.item_find(4115)
	if (itemA != OBJ_HANDLE_NULL):
		itemA.destroy()
		create_item_in_inventory( 4115, triggerer )
	itemB = attachee.item_find(6016)
	if (itemB != OBJ_HANDLE_NULL):
		itemB.destroy()
		create_item_in_inventory( 6016, triggerer )
	itemC = attachee.item_find(6023)
	if (itemC != OBJ_HANDLE_NULL):
		itemC.destroy()
		create_item_in_inventory( 6023, triggerer )
	itemD = attachee.item_find(4213)
	if (itemD != OBJ_HANDLE_NULL):
		itemD.destroy()
		create_item_in_inventory( 4213, triggerer )
	create_item_in_inventory( 7001, attachee )
	create_item_in_inventory( 7001, attachee )
	return RUN_DEFAULT

def switch_to_tarah( attachee, triggerer, line):
	npc = find_npc_near(attachee,8805)
	fruella = find_npc_near(attachee,8067)
	if (npc != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc, line)
		npc.turn_towards(fruella)
		fruella.turn_towards(npc)
	return SKIP_DEFAULT
